<?php

namespace App\Http\Controllers\Api\V2;

use Illuminate\Http\Request;
use App\Http\Requests\ApiV2\VendorRequest;
use App\Services\Warehouse\Interfaces\VendorServiceInterface;
use Illuminate\Support\Facades\DB;
use App\Services\Warehouse\Services\VendorService;

class VendorController extends BaseController
{
    /**
     * @var Vendor
     */
    protected $vendorService;

    public function __construct(VendorServiceInterface $vendorService)
    {
        $this->vendorService = $vendorService;
    }


    public function index(Request $request)
    {
        $vendor = $this->vendorService->index($request->all());
        return $this->data($vendor);
    }

    public function store(VendorRequest $request)
    {
        $this->vendorService->set($request->filldata());
        return $this->success();
    }

    public function edit($id)
    {
        $vendor = $this->vendorService->get($id);
        return $this->data($vendor);
    }

    public function update(VendorRequest $request, $id)
    {
        $this->vendorService->set($request->filldata(), $id);
        return $this->success();
    }

    public function destroy($id)
    {
        $this->vendorService->destroy($id);
        return $this->success();
    }
}
